package com.ruoyi.mespro.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mespro.domain.AlldataSizing;
import com.ruoyi.mespro.service.IAlldataSizingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 浆纱机实时数据Controller
 * 
 * @author Jun Xiang
 * @date 2022-06-07
 */
@RestController
@RequestMapping("/realtime/size")
public class AlldataSizingController extends BaseController
{
    @Autowired
    private IAlldataSizingService alldataSizingService;

    /**
     * 查询浆纱机实时数据列表
     */
    @PreAuthorize("@ss.hasPermi('realtime:size:list')")
    @GetMapping("/list")
    public TableDataInfo list(AlldataSizing alldataSizing)
    {
        startPage();
        List<AlldataSizing> list = alldataSizingService.selectAlldataSizingList(alldataSizing);
        return getDataTable(list);
    }

    /**
     * 导出浆纱机实时数据列表
     */
    @PreAuthorize("@ss.hasPermi('realtime:size:export')")
    @Log(title = "浆纱机实时数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AlldataSizing alldataSizing)
    {
        List<AlldataSizing> list = alldataSizingService.selectAlldataSizingList(alldataSizing);
        ExcelUtil<AlldataSizing> util = new ExcelUtil<AlldataSizing>(AlldataSizing.class);
        return util.exportExcel(list, "浆纱机实时数据数据");
    }

    /**
     * 获取浆纱机实时数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('realtime:size:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(alldataSizingService.selectAlldataSizingById(id));
    }

    /**
     * 新增浆纱机实时数据
     */
    @PreAuthorize("@ss.hasPermi('realtime:size:add')")
    @Log(title = "浆纱机实时数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AlldataSizing alldataSizing)
    {
        return toAjax(alldataSizingService.insertAlldataSizing(alldataSizing));
    }

    /**
     * 修改浆纱机实时数据
     */
    @PreAuthorize("@ss.hasPermi('realtime:size:edit')")
    @Log(title = "浆纱机实时数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AlldataSizing alldataSizing)
    {
        return toAjax(alldataSizingService.updateAlldataSizing(alldataSizing));
    }

    /**
     * 删除浆纱机实时数据
     */
    @PreAuthorize("@ss.hasPermi('realtime:size:remove')")
    @Log(title = "浆纱机实时数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(alldataSizingService.deleteAlldataSizingByIds(ids));
    }
}
